{extend name="common:base" /}
{block name="content"}
<div class="row">
    <a class="btn btn-info" href="{:url('add')}" value="">新增</a>
</div>
<div class="space-4"></div>
<div class="row">
<form id="form" method="post" action="{:url('index',['act'=>'del'])}">
<table class="table table-striped table-bordered">
<thead>
    <tr>
        <th class="center col-xs-1"><input class="check-all" type="checkbox" value=""></th>
        <th class="col-xs-5">分类名称</th>
        <th class="col-xs-2">类型</th>
        <th class="col-xs-2">排序</th>
        <th class="col-xs-2">操作</th>
    </tr>
</thead>
<tbody>
{volist name="category" id="v"}
<tr>
    <td class="center"><input class="ids" type="checkbox" name="ids[]" value="{$v.id}"></td>
    <td>{$v.name}</td>
    <td>{if condition="$v.type eq 0"}文章{/if}{if condition="$v.type eq 1"}外链{/if}</td>
    <td>{$v.o}</td>
    <td>
        <a class="blue" href="{:url('edit',array('id'=>$v.id))}" title="编辑分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>编辑</a>&nbsp;&nbsp;
        <a class="green" href="{:url('add',array('pid'=>$v.id))}" title="新增分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>新增</a>
    </td>
</tr>
{notempty name="v.children"}
{volist name="v.children" id="vv"}
<tr>
    <td class="center"><input class="ids" type="checkbox" name="ids[]" value="{$vv.id}"></td>
    <td>┣━{$vv.name}</td>
    <td>{if condition="$vv.type eq 0"}文章{/if}{if condition="$vv.type eq 1"}外链{/if}</td>
    <td>{$vv.o}</td>
    <td>
        <a class="blue" href="{:url('edit',array('id'=>$vv.id))}" title="编辑分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>编辑</a>&nbsp;&nbsp;
        <a class="green" href="{:url('add',array('pid'=>$vv.id))}" title="新增分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>新增</a>
    </td>
</tr>
{notempty name="vv.children"}
{volist name="vv.children" id="vvv"}
<tr>
    <td class="center"><input class="ids" type="checkbox" name="ids[]" value="{$vvv.id}"></td>
    <td>┣━━{$vvv.name}</td>
    <td>{if condition="$vvv.type eq 0"}文章{/if}{if condition="$vvv.type eq 1"}外链{/if}</td>
    <td>{$vvv.o}</td>
    <td>
        <a class="blue" href="{:url('edit',array('id'=>$vvv.id))}" title="编辑分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>编辑</a>&nbsp;&nbsp;
        <a class="green" href="{:url('add',array('pid'=>$vvv.id))}" title="新增分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>新增</a>
    </td>
</tr>
{notempty name="vvv.children"}
{volist name="vvv.children" id="vvvv"}
<tr>
    <td class="center"><input class="ids" type="checkbox" name="ids[]" value="{$vvvv.id}"></td>
    <td>┣━━━{$vvvv.name}</td>
    <td>{if condition="$vvvv.type eq 0"}文章{/if}{if condition="$vvvv.type eq 1"}外链{/if}</td>
    <td>{$vvvv.o}</td>
    <td>
        <a class="blue" href="{:url('edit',array('id'=>$vvvv.id))}" title="编辑分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>编辑</a>
    </td>
</tr>
{/volist}
{/notempty}
{/volist}
{/notempty}
{/volist}
{/notempty}
{/volist}
</tbody>
</table>
</form>
</div>
<div class="row">
    <input id="submit" class="btn btn-info" type="button" value="删除">
</div>
{/block}
{block name="js_file"}
<script src="__ADMIN__/js/bootbox.js"></script>
{/block}
{block name="javascript"}
<script type="text/javascript">
$(function(){
    $(".check-all").click(function(){
        $(".ids").prop("checked", this.checked);
    });
    $(".ids").click(function(){
        var option = $(".ids");
        option.each(function(i){
            if(!this.checked){
                $(".check-all").prop("checked", false);
                return false;
            }else{
                $(".check-all").prop("checked", true);
            }
        });
    });
    $("#submit").click(function(){
        bootbox.confirm({
            title: "警告",
            message: "确定要删除所选分类？", 
            callback:function(result){
                if(result){
                    $("#form").submit();
                }
            },
            buttons: {
                "cancel" : {"label" : "取消"},
                "confirm" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
            }
        });
    });
})
</script>
{/block}